import React,{Component} from "react";
class DemosetStateAttr extends Component {
  state = { 
    userinfo:{
      role:'admin',
      age:18,
      email:'132qq.com'
    }
   }
   changeUser=(email)=>{
    let userinfo = this.state.userinfo
    userinfo.email = email
    this.setState({
      userinfo
    })
   }
  render() { 
    return ( 
      <div>
        <h3>8.1 修改state对象下面的某个属性</h3>
        <p>邮箱:{this.state.userinfo.email}</p>
        <button onClick={()=>this.changeUser('583qq.com')}>修改邮箱地址</button>
      </div>
     );
  }
}
 
export default DemosetStateAttr;